package com.hua.yuan.live.fragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.hua.yuan.BaseFragment;
import com.hua.yuan.live.R;
import com.hua.yuan.live.repertory.cloud_data.loader.LiveAttentationLoader;
import com.hua.yuan.live.repertory.cloud_data.res.RoomInfoBean;
import com.hua.yuan.live.view.BlackView;
import com.hua.yuan.live.view.anchor.ResumeView;
import com.jet.flowtaglayout.FlowTagLayout;

import java.util.ArrayList;
import java.util.List;

import static android.view.View.GONE;

/**
 * 主播简历 TODO zyb代码反了，需要fragment去请求数据，更新外部的activity信息
 */
public class AnchorResumeFragment extends BaseFragment
{

    private int mAttentation;

    private ResumeView mResumeView;

    private BlackView mBlackView;

    private ViewGroup mView;

    private Handler handler=new Handler();

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mView= (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.fragment_personal_resume,null);
        mResumeView=new ResumeView(mView);
        mBlackView=new BlackView(getActivity());
        mBlackView.setTitle(getActivity().getResources().getString(R.string.common_loading_title));
        mBlackView.setSubTitle(getActivity().getResources().getString(R.string.common_loading_subtitle));
        mView.addView(mBlackView.getCurrentView());
        return mView;
    }


    @SuppressLint({"StringFormatMatches", "StringFormatInvalid"})
    public void setData(final RoomInfoBean pRoomInfoBean){
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                if(TextUtils.isEmpty(pRoomInfoBean.getAutograph()) &&
                        TextUtils.isEmpty(pRoomInfoBean.getHeight()) &&
                        TextUtils.isEmpty(pRoomInfoBean.getCity()) &&
                        TextUtils.isEmpty(pRoomInfoBean.getConstellation()) &&
                        TextUtils.isEmpty(pRoomInfoBean.getProfession())
                        ) {
                    mResumeView.setVisible(View.GONE);
                    mBlackView.setTitle(getActivity().getResources().getString(R.string.anchor_resume_black));
                    mBlackView.setSubTitle(getActivity().getResources().getString(R.string.anchor_resume_black_subtitle));
                    mBlackView.setVisible(View.VISIBLE);
                    return;
                }
                mResumeView.setData(pRoomInfoBean, getActivity().getApplicationContext());
                mResumeView.setVisible(View.VISIBLE);
                mBlackView.setVisible(GONE);

            }
        },300);

    }

}

